home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Utilities / Post / Source / postasm.s < prev    next >
Encoding:
Text File  |  1997-04-01  |  6.2 KB  |  188 lines

  1. |***************************************************************************
  2. |
  3. | PostScript interpreter file "postasm.a" - assembler routines (Amiga)
  4. | (C) Adrian Aylward 1989, 1991
  5. |
  6. | This file contains the assembler support routines for the main program.
  7. | It is Lattice specific.
  8. |
  9. |***************************************************************************
  10.  
  11. ThisTask         = 276
  12. TC_EXCEPTCODE    = 42
  13. TC_TRAPCODE      = 50
  14. SIGBREAKB_CTRL_C = 12
  15. AttnFlags        = 296
  16.  
  17. |***************************************************************************
  18. |
  19. | The text segment
  20. |
  21. |***************************************************************************
  22.  
  23.         .text
  24.  
  25.         .extern _sigintmain
  26.         .extern _sigint
  27.         .extern _sigfpe
  28.  
  29.         .global _insertbreakmain
  30.         .global _deletebreakmain
  31.         .global _insertbreak
  32.         .global _deletebreak
  33.         .global _insertftrap
  34.         .global _deleteftrap
  35.  
  36. |***************************************************************************
  37. |
  38. | Insert the break exception handler
  39. |
  40. |***************************************************************************
  41.  
  42. _insertbreakmain:
  43.         move.l  4,a0                            | Get ExecBase
  44.         move.l  ThisTask(a0),a0                 | Locate our task
  45.         move.l  TC_EXCEPTCODE(a0),sxcodemain    | Save old handler
  46.         move.l  #hbreakmain,TC_EXCEPTCODE(a0)   | Insert new handler
  47.         rts
  48.  
  49. _insertbreak:
  50.         move.l  4,a0                            | Get ExecBase
  51.         move.l  ThisTask(a0),a0                 | Locate our task
  52.         move.l  TC_EXCEPTCODE(a0),sxcode        | Save old handler
  53.         move.l  #hbreak,TC_EXCEPTCODE(a0)       | Insert new handler
  54.         rts
  55.  
  56. |***************************************************************************
  57. |
  58. | Delete the break exception handler
  59. |
  60. |***************************************************************************
  61.  
  62. _deletebreakmain:
  63.         move.l  4,a0                            | Get ExecBase
  64.         move.l  ThisTask(a0),a0                 | Locate our task
  65.         move.l  sxcodemain,TC_EXCEPTCODE(a0)    | Restore old handler
  66.         rts
  67.  
  68. _deletebreak:
  69.         move.l  4,a0                            | Get ExecBase
  70.         move.l  ThisTask(a0),a0                 | Locate our task
  71.         move.l  sxcode,TC_EXCEPTCODE(a0)        | Restore old handler
  72.         rts
  73.  
  74. |***************************************************************************
  75. |
  76. | The break exception handler
  77. |
  78. |***************************************************************************
  79.  
  80. hbreakmain:
  81.         btst    #SIGBREAKB_CTRL_C,d0      | if this a CTRL/C
  82.         beq.s   hb1m
  83.         movem.l d0/d1/a0/a1,-(sp)
  84.         moveq   #1,d0
  85.         move.l  d0,-(sp)
  86.         jsr     _sigintmain               | signal interrupt
  87.         addq.l  #4,sp
  88.         movem.l (sp)+,d0/d1/a0/a1
  89. hb1m:   rts
  90.  
  91. hbreak:
  92.         btst    #SIGBREAKB_CTRL_C,d0      | if this a CTRL/C
  93.         beq.s   hb1
  94.         movem.l d0/d1/a0/a1,-(sp)
  95.         moveq   #1,d0
  96.         move.l  d0,-(sp)
  97.         jsr     _sigint                   | signal interrupt
  98.         addq.l  #4,sp
  99.         movem.l (sp)+,d0/d1/a0/a1
  100. hb1:    rts
  101.  
  102. |***************************************************************************
  103. |
  104. | Insert the floating point trap handler
  105. |
  106. |***************************************************************************
  107.  
  108. _insertftrap:
  109.         move.l  a6,-(sp)
  110.         move.l  4,a6                      | Get ExecBase
  111.         btst    #4,AttnFlags+1(a6)        | See if we have an FPU
  112.         beq.s   if1
  113.         move.l  ThisTask(a6),a0           | Locate our task
  114.         move.l  TC_TRAPCODE(a0),stcode    | Save old hanmdler
  115.         move.l  #sftrap,TC_TRAPCODE(a0)   | Insert new handler
  116.         fmove.l fpcr,d0
  117.         move.l  d0,sfpcr                  | Save fpcr
  118.         or.w    #0xfd90,d0                | Set trap flags in fpcr
  119.         fmove.l d0,fpcr
  120. if1:    move.l  (sp)+,a6
  121.         rts
  122.  
  123. |***************************************************************************
  124. |
  125. | Delete the floating point trap handler
  126. |
  127. |***************************************************************************
  128.  
  129. _deleteftrap:
  130.         move.l  a6,-(sp)
  131.         move.l  4,a6                      | Get ExecBase
  132.         btst    #4,AttnFlags+1(a6)        | See if we have an FPU
  133.         beq.s   df1
  134.         move.l  sfpcr,d0                  | Restore fpcr
  135.         fmove.l d0,fpcr
  136.         move.l  ThisTask(a6),a0           | Locate our task
  137.         move.l  stcode,TC_TRAPCODE(a0)    | Restore old hanmdler
  138. df1:    move.l  (sp)+,a6
  139.         rts
  140.  
  141. |***************************************************************************
  142. |
  143. | The floating point trap handler
  144. |
  145. |***************************************************************************
  146.  
  147. sftrap: cmp.l   #48,(sp)                  | fp traps are 48 - 54
  148.         bcs.s   ht1
  149.         cmp.l   #54,(sp)
  150.         bls.s   ht2
  151. ht1:    move.l  stcode,-(sp)              | not fp, jump to old handler
  152.         rts
  153.  
  154. ht2:    move.l  d0,-(sp)
  155.         fsave   -(a7)                     | save FPU internal state
  156.         move.b  0(a7),d0                  | first byte of FPU state frame
  157.         beq.s   ht3                       | branch on null state frame
  158.  
  159.         moveq   #0,D0
  160.         move.b  1(a7),d0                  | load state frame size (in bytes)
  161.         bset    #3,0(a7,d0.l)             | set FPU exception pending bit (27)
  162.  
  163. ht3:    frestore (a7)+                    | restore FPU internal state
  164.         addq.l  #4,sp                     | discard trap number
  165.         move.l  #uftrap,2(sp)             | update pc with user trap handler
  166.         rte                               | return to user state, enter trap
  167.  
  168. uftrap: move.l  4,a6                      | Get ExecBase
  169.         jsr     _sigfpe                   | signal fp error, no return
  170.  
  171. |***************************************************************************
  172. |
  173. | The data segment (bss)
  174. |
  175. |***************************************************************************
  176.  
  177. |       CSECT   __MERGED,2                | BSS
  178.  
  179. sxcodemain: ds.b    4                     | Saved exception code
  180. sxcode:     ds.b    4                     | Saved exception code
  181. stcode:     ds.b    4                     | Saved trap code
  182.  
  183. sfpcr:      ds.b    4                     | Saved fpcr
  184.  
  185. |       end
  186.  
  187. | End of file "postasm.a"
  188.